﻿using System;
using System.Collections.Generic;
using System.Text;

namespace XendApp
{
    public class Message
    {
        public enum ContentT
        {
            PlainText = 1,
            HTML = 2
        }

        private ContentT m_contentType = ContentT.PlainText;
        /// <summary>
        /// Content type of message
        /// </summary>
        public ContentT ContentType
        {
            get { return m_contentType; }
            set { m_contentType = value; }
        }

        private Guid m_channelId;
        /// <summary>
        /// Id of target channel. See web site for channel Id
        /// </summary>
        public Guid ChannelId
        {
            get { return m_channelId; }
            set { m_channelId = value; }
        }

        private string m_subject;
        /// <summary>
        /// Subject of message
        /// </summary>
        public string Subject
        {
            get { return m_subject; }
            set { m_subject = value; }
        }

        private string m_body;
        /// <summary>
        /// Body of message
        /// </summary>
        public string Body
        {
            get { return m_body; }
            set { m_body = value; }
        }

        private bool m_encrypted = false;
        /// <summary>
        /// If message should be encrypted or not
        /// </summary>
        public bool Encrypted
        {
            get { return m_encrypted; }
            set { m_encrypted = value; }
        }

        private int m_expiredays;
        /// <summary>
        /// Number of days before message expiration. Maximum is 90 days.
        /// </summary>
        public int ExpireDays
        {
            get { return m_expiredays; }
            set {
                if (value > 90)
                {
                    m_expiredays = 90; 
                }
                else
                {
                    m_expiredays = value; 
                }
            }
        }

        /// <summary>
        /// Set expiry date based on future date
        /// </summary>
        /// <param name="dteExpire"></param>
        public void SetExpireDate(DateTime dteExpire)
        {
            ExpireDays = Convert.ToInt32(dteExpire.Subtract(DateTime.Now).TotalDays);
        }
    }
}
